# -*- coding:utf-8 -*-

__author__='zhaoxp'

import urllib
import urllib2
import base64

def test_HTTP_authenticate():
    print('logon example')
    url='http://plmtest.lenovo.com/Windchill/wtcore/jsp/jmx/serverStatus.jsp'
    username='wcadmin'
    password='tpgqas0912x'
    headers={'Authorization':'Basic %s'%base64.encodestring('%s:%s'%(username,password))}
    print(username)
    print(password)
    print(headers)
    request=urllib2.Request(url,headers=headers)
    try:
        f=urllib2.urlopen(request)
        #print(f.read())
        print(f.getcode())
    except urllib2.HTTPError as he:
        print('Error : %s'%he)
        print(type(he))
        print(he.getcode())
        print(dir(he))
    #f=urllib.urlopen('http://%s:%s@plmtest.lenovo.com/Windchill/wtcore/jsp/jmx/serverStatus.jsp'%(username,password))

if __name__=='__main__':
    print('show example about how to use list as arguemnt')
    test_HTTP_authenticate()
    
    